package controllers;

import java.util.Map;
import play.*;
import play.mvc.*;
import play.data.*;
import views.html.*;
import models.*;
import play.data.DynamicForm;


public class Application extends Controller {
  
    public static Result index() {
        return redirect(routes.Application.viewStopSearch());
    }
      
    public static Result viewStopSearch() {
        return ok(searchStop.render("ITRACT: Search"));
    }
    
    public static Result viewStop(String stopName) {
        Stop stop = Stop.getByName(stopName);
        return ok(viewStop.render("ITRACT: Stop", stop));
    }
    
    public static Result executeStopSearch() {
        //get POST information
        DynamicForm form = form().bindFromRequest();
        String stopName = form.get("stopName");
        return redirect(routes.Application.viewStop(stopName));
    }

}